<template>
  <div class="newsinfo">
    <h3 class="newinfo-h3">{{getnewsinfo.title}}</h3>
    <p class="newinfo-p">
      <span>发表时间:{{getnewsinfo.add_time | dataFomat}}</span>
      <span>点击:{{getnewsinfo.click}}次</span>
    </p>
    <hr>
    <div v-html="getnewsinfo.content"></div>
    <comment :id="id"></comment>
  </div>
</template>
<script>
import comment from '../subcponents/comment.vue';
export default {
  data() {
    return {
      getnewsinfo: {},
      id: this.$route.params.id
    };
  },
  created() {
    this.getNewsInfo();
  },
  methods: {
   async getNewsInfo() {
     await this.$http.get("api/getnew/" + this.id).then(result => {
        if (result.data.status === 0) {
          this.getnewsinfo = result.data.message[0];
        }
      });
    }
  },
  components:{
      "comment":comment
  }
};
</script>
<style>
.newsinfo {
  padding: 5px;
}
.newinfo-h3 {
  text-align: center;
  color: red;
  font-size: 16px;
  font-weight: bold;
}
.newinfo-p {
  display: flex;
  justify-content: space-between;
}
.newinfo-p img {
  width: 100%;
}
</style>